/* ==============================================================================
 * 创 建 者：lyt
 * 创建日期：2017-07-14	
 * 功能描述：

 * 修 改 人:
 * 修改时间:
 * 修改描述：
 * ==============================================================================*/
//获取密保问题
var GetQuestionListUrl = baseUrl+'common/GetQuestionList';
//设置密保问题
var SetAnswerUrl = baseUrl+'MemberF/SetAnswer';
//会员信息获取
var getMemberViewUrl = baseUrl + 'MemberF/MemberView';

var vu;
$(function(){
	initVue();
});

function initVue(){
	vu = new Vue({
		el : '#content',
		data : {
			member : '',
			List : [],
			newQuestion : '',
			newAnswer : '',
			oldQuestion : '',
			oldAnswer : '',
		},
		mounted: function() {
			this.GetQuestionList();
			this.getMemberView();
		},
		methods : {
			GetQuestionList : GetQuestionList,
			Submit : Submit,
			getMemberView : getMemberView,
		}
	})
}

function Submit(){
	var data = {
		newQuestion : vu.newQuestion,
		newAnswer : vu.newAnswer,
		oldQuestion : vu.oldQuestion,
		oldAnswer : vu.oldAnswer,
	}
	common.post(SetAnswerUrl, data,'json',function(r){
		if(r.ErrorCode==0){
			mui.toast(r.ErrorMsg);
			vu.newQuestion = '';
			vu.newAnswer = '';
			vu.oldQuestion = '';
			vu.oldAnswer = '';
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}

function GetQuestionList(){
	common.post(GetQuestionListUrl,{},'json',function(r){
		if(r.ErrorCode==0){
			vu.List = r.Data.List;
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}

function getMemberView(){
	common.get(getMemberViewUrl,{},'json',function(r){
		if(r.ErrorCode==0){
			vu.member = r.Data.member;
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}
